import tensorflow as tf

y = tf.constant([1, 2, 3, 0, 2])
y = tf.one_hot(y, depth=4)
y = tf.cast(y, dtype=tf.float32)
print(y)

# 模拟logits
out = tf.random.normal([5, 4])
print(out)

loss1 = tf.reduce_mean(tf.square(y - out))
print(loss1)

loss2 = tf.square(tf.norm(y - out)) / (5 * 4)
print(loss2)

mse = tf.losses.MSE(y, out)
print(mse)
loss3 = tf.reduce_mean(tf.losses.MSE(y, out))
print(loss3)
